package com.tudouji.project.mt.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.mt.domain.MtWhinitem;
import com.tudouji.project.mt.service.IMtWhinitemService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 美团入库明细Controller
 * 
 * @author tudouji
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/mt/whinitem")
public class MtWhinitemController extends BaseController
{
    @Autowired
    private IMtWhinitemService mtWhinitemService;

    /**
     * 查询美团入库明细列表
     */
    @PreAuthorize("@ss.hasPermi('mt:whinitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(MtWhinitem mtWhinitem)
    {
        startPage();
        List<MtWhinitem> list = mtWhinitemService.selectMtWhinitemList(mtWhinitem);
        return getDataTable(list);
    }

    /**
     * 导出美团入库明细列表
     */
    @PreAuthorize("@ss.hasPermi('mt:whinitem:export')")
    @Log(title = "美团入库明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MtWhinitem mtWhinitem)
    {
        List<MtWhinitem> list = mtWhinitemService.selectMtWhinitemList(mtWhinitem);
        ExcelUtil<MtWhinitem> util = new ExcelUtil<MtWhinitem>(MtWhinitem.class);
        return util.exportExcel(list, "whinitem");
    }

    /**
     * 获取美团入库明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('mt:whinitem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mtWhinitemService.selectMtWhinitemById(id));
    }

    /**
     * 新增美团入库明细
     */
    @PreAuthorize("@ss.hasPermi('mt:whinitem:add')")
    @Log(title = "美团入库明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MtWhinitem mtWhinitem)
    {
        return toAjax(mtWhinitemService.insertMtWhinitem(mtWhinitem));
    }

    /**
     * 修改美团入库明细
     */
    @PreAuthorize("@ss.hasPermi('mt:whinitem:edit')")
    @Log(title = "美团入库明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MtWhinitem mtWhinitem)
    {
        return toAjax(mtWhinitemService.updateMtWhinitem(mtWhinitem));
    }

    /**
     * 删除美团入库明细
     */
    @PreAuthorize("@ss.hasPermi('mt:whinitem:remove')")
    @Log(title = "美团入库明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mtWhinitemService.deleteMtWhinitemByIds(ids));
    }
}
